package com.example.demo.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * Created by lyc on 2019/5/31.
 */
@Configuration
public class ValidatorConfig {


    @Bean
    public Validator validator(){
        Validator validator = Validation.byProvider(HibernateValidator.class)
                                            .configure()
                                            //.failFast(true)//快速失败
                                            .buildValidatorFactory()
                                            .getValidator();
        return validator;
    }
}
